In [1]:
import matplotlib.pyplot as plt
%matplotlib inline
import matplotlib as mpl
import matplotlib.cm as cm
mpl.rcParams['figure.figsize'] = (7, 7)
plt.style.use('bmh')
mpl.__version__
import skimage
from skimage import filter
from skimage.transform import hough_circle
from skimage.feature import peak_local_max
from skimage.draw import circle_perimeter
import glob
import numpy as np

In [2]:
from saaspy.image import image, find_center
from saaspy.collection import collection

In [3]:
dir = "/Users/schriste/Desktop/SAAS/"

list of files taken during calibration. See SAAS labnotebook for a list of what each one is.


In [4]:
fits_files1 = glob.glob('/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_*.fits')
fits_files2 = glob.glob('/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_*.fits')
fits_files = fits_files1 + fits_files2

Finding the Calibrated SAAS Center (2014/11/09)


In [5]:
fits_files


Out[5]:
['/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_145025.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_145045.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_160625.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_160815.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_162135.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_191718.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_192308.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_205930.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_210137.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_210157.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_222103.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_231002.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_232440.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_232446.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_232644.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_233520.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_234336.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_234339.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_235421.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_235428.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_000232.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_000818.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_001342.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_001842.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_003437.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_003449.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_003516.fits']

In [6]:
cl = collection(fits_files[2:])

In [7]:
cl.data


Out[7]:
filename max min mindex_x mindex_y std
2014-11-09 16:06:25 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 57 0 532 683 1.493803
2014-11-09 16:08:15 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 50 0 531 684 1.542214
2014-11-09 16:21:35 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 255 0 483 662 7.421288
2014-11-09 19:17:18 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 178 0 474 658 4.958910
2014-11-09 19:23:08 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 182 0 493 638 5.543836
2014-11-09 20:59:30 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 91 0 454 647 2.417675
2014-11-09 21:01:37 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 88 0 454 648 2.392515
2014-11-09 21:01:57 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 84 0 454 648 2.402917
2014-11-09 22:21:03 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 75 0 454 647 2.309549
2014-11-09 23:10:02 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 70 0 451 647 2.286675
2014-11-09 23:24:40 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 79 0 452 647 2.241053
2014-11-09 23:24:46 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 81 0 452 647 2.240780
2014-11-09 23:26:44 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 82 0 453 647 2.238706
2014-11-09 23:35:20 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 72 0 452 646 2.233990
2014-11-09 23:43:36 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 7 0 661 1158 0.885881
2014-11-09 23:43:39 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 73 0 454 648 2.236104
2014-11-09 23:54:21 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 66 0 181 666 2.296055
2014-11-09 23:54:28 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 66 0 162 646 2.294131
2014-11-10 00:02:32 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 65 0 373 640 2.243764
2014-11-10 00:08:18 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 70 0 377 644 2.224841
2014-11-10 00:13:42 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 72 0 446 749 2.233118
2014-11-10 00:18:42 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 76 0 444 748 2.232541
2014-11-10 00:34:37 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 255 0 320 816 46.719093
2014-11-10 00:34:49 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 255 0 314 986 77.122434
2014-11-10 00:35:16 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110... 255 0 861 555 20.936391

Checking out one random file


In [8]:
index = -10
s1 = image(fits_files[index])
print(fits_files[index])


/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_234339.fits

In [9]:
s1.imshow()
s1.overlay()
plt.colorbar()


Out[9]:
<matplotlib.colorbar.Colorbar instance at 0x10adb05a8>

In [10]:
plt.imshow(s1.data, origin='upper', cmap=cm.Greys_r)
plt.colorbar()


Out[10]:
<matplotlib.colorbar.Colorbar instance at 0x1105d68c0>

In [11]:
s1.hist()



In [12]:
s1.roi_auto()
s1.imshow()
plt.colorbar()


Out[12]:
<matplotlib.colorbar.Colorbar instance at 0x1118c7908>

In [13]:
s1.roi


Out[13]:
array([ 598.,  698.,  404.,  504.])

In [14]:
#find_center(s1, sigma=0.75)

Gathering all of image maxima


In [15]:
cl.data.plot(subplots=True)


Out[15]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x111797710>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x111a60a50>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x111ae6410>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x111b47f10>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x111bcac90>], dtype=object)

From the plots below you can see when the position was stable (from index 5 to 13) and when the offpointing occured. This is corraborated by comparing to the X-ray alignment images


In [16]:
x = cl.data['mindex_x'].values
y = cl.data['mindex_y'].values
fig, (ax1, ax2) = plt.subplots(ncols=2)
ax1.plot(x)
ax2.plot(y)
plt.show()


Calibrated Center

using only image max


In [17]:
print(np.average(x[5:13]), np.std(x[5:13]))


(453.0, 1.1180339887498949)

In [18]:
print(np.average(y[5:13]), np.std(y[5:13]))


(647.25, 0.4330127018922193)

The camera was moved during staking which invalidates this value

Finding the calibrated center using Hough Transform

definitely need some tweeking


In [19]:
#x_hough = []
#y_hough = []
#i = 0
#for f in fits_files[2:]:
#    s = saas_img(f)
##    x_hough.append(s.find_center(sigma=0.8)[0])
#    y_hough.append(s.find_center(sigma=0.8)[1])
#    print(i, x_hough, y_hough, f)
#    i = i + 1

Determing plate scale


In [20]:
s = []
plate_scale_files = ['FOXSI_SAAS_141110_003437.fits', 
                     'FOXSI_SAAS_141110_003449.fits', 
                     'FOXSI_SAAS_141110_003516.fits']
for f in plate_scale_files:
    s.append(image(dir + f))

In [21]:
s[0].imshow()



In [22]:
s[1].imshow()



In [23]:
s[2].imshow()


Probably the best image


In [24]:
best_img = s[0]
best_img.imshow()



In [25]:
best_img.roi = [500, 1000, 400, 800]
best_img.imshow()
x1 = [752, 914]
y1 = [756, 438]
x2 = [752, 928]
y2 = [756, 423]
plt.plot(x1, y1)
plt.plot(x2, y2)


Out[25]:
[<matplotlib.lines.Line2D at 0x111914fd0>]

In [26]:
r1 = np.sqrt((x1[0] - x1[1]) ** 2 + (y1[0] - y1[1]) ** 2)
r2 = np.sqrt((x2[0] - x2[1]) ** 2 + (y2[0] - y2[1]) ** 2)
pixels = np.array([np.average([r1,r2]), np.std([r1,r2])])
print(pixels)


[ 366.76812061    9.88158402]

measured distance from Van, from laser center to rounded edge = 4.878 inches above. Alignment stand was 20.85 meters away

angular distance of features is


In [27]:
np.rad2deg(np.arctan(0.1239/20.85))*60*60


Out[27]:
1225.7030542494363

This means that the plate scale is (per pixel)


In [28]:
1225/366.78


Out[28]:
3.3398767653634334

confirming with other direction


In [29]:
best_img.imshow()
x1 = [752, 961]
y1 = [756, 756]
x2 = [752, 961]
y2 = [756, 756]
plt.plot(x1, y1)
plt.plot(x2, y2)


Out[29]:
[<matplotlib.lines.Line2D at 0x115365e50>]

In [30]:
r1 = np.sqrt((x1[0] - x1[1]) ** 2 + (y1[0] - y1[1]) ** 2)
r2 = np.sqrt((x2[0] - x2[1]) ** 2 + (y2[0] - y2[1]) ** 2)
pixels = np.array([np.average([r1,r2]), np.std([r1,r2])])
print(pixels)


[ 209.    0.]

perpendicular measured distance from laser center to right edge = 3.15 inches.

angular distance is then


In [31]:
np.rad2deg(np.arctan(0.08/20.85))*60*60


Out[31]:
791.41983326023842

The plate scale is then


In [32]:
791.4/209


Out[32]:
3.786602870813397

This seems much too large compared to the other measurement

Determining Phasing


In [33]:
fits_files


Out[33]:
['/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_145025.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_145045.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_160625.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_160815.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_162135.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_191718.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_192308.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_205930.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_210137.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_210157.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_222103.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_231002.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_232440.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_232446.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_232644.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_233520.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_234336.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_234339.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_235421.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141109_235428.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_000232.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_000818.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_001342.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_001842.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_003437.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_003449.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141110_003516.fits']

Back of payload moved UP


In [34]:
up = [dir + 'FOXSI_SAAS_141109_235421.fits', dir + 'FOXSI_SAAS_141109_235428.fits']
saas_up = [image(up[0]), image(up[1])]

Back of the payload moved less UP


In [35]:
less_up = dir + 'FOXSI_SAAS_141110_000232.fits'
saas_less_up = image(less_up)

Back of the payload moved to the RIGHT (looking sunward)


In [36]:
right = dir + 'FOXSI_SAAS_141110_001342.fits'
saas_right = image(right)

In [37]:
cal = dir + 'FOXSI_SAAS_141109_205930.fits'

In [38]:
cal_saas = image(cal)

In [39]:
cal_saas.roi_reset()
plt.imshow(cal_saas.data, origin='upper', cmap=cm.Greys_r)
plt.contour(saas_right.data)
plt.contour(saas_up[0].data)
plt.contour(saas_less_up.data)


Out[39]:
<matplotlib.contour.QuadContourSet instance at 0x118b4bfc8>

In [40]:
plt.imshow(saas_up[0].data, origin='upper')


Out[40]:
<matplotlib.image.AxesImage at 0x11b5eb850>

Must use origin=upper to get the proper orientation in Y!!!

using origin='lower' shows the uncorrected image as shown on the uncorrected SAAS display


In [41]:
fits_files1 = glob.glob('/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113*')

In [42]:
fits_files1


Out[42]:
['/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_041404.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_043052.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_043053.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_203247.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_204328.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_204417.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_205058.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_205709.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_214302.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_214555.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_224732.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_224957.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141113_225304.fits']

In [43]:
sparcs = image(fits_files1[-1])
no_sparcs = image(fits_files1[-4])

In [44]:
sparcs.roi_reset()
plt.figure()
plt.imshow(sparcs.data, cmap=cm.Greys_r, origin='upper')
xy = np.shape(no_sparcs.data)
plt.contour(no_sparcs.data)


Out[44]:
<matplotlib.contour.QuadContourSet instance at 0x11569efc8>

In [45]:
def find_center(img, sigma=0.9, num_circles=1):
    edges = filter.canny(img, sigma=sigma)
    hough_radii = np.arange(200, 500, 5)
    hough_res = hough_circle(edges, hough_radii)
    centers = []
    accums = []
    radii = []
    for radius, h in zip(hough_radii, hough_res):
        # For each radius, extract two circles
        peaks = peak_local_max(h, num_peaks=2)
        if peaks != []:
            centers.extend(peaks)
            accums.extend(h[peaks[:, 0], peaks[:, 1]])
            radii.extend([radius, radius])

    best_centers = []
    best_radii = []
    best_x = []
    best_y = []
    number_of_best_circles = num_circles
    for idx in np.argsort(accums)[::-1][:number_of_best_circles]:
        center_x, center_y = centers[idx]
        best_x.append(center_x)
        best_y.append(center_y)
        best_centers.append(centers[idx])
        best_radii.append(radii[idx])

    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 6))
    ax1.imshow(edges)
    ax2.imshow(img, cmap=cm.gray)
    for center, radius in zip(best_centers, best_radii):
        circle = plt.Circle((center[1], center[0]), radius, color='r', fill=False)
        ax2.add_patch(circle)
        plt.axvline(center[1])
        plt.axhline(center[0])
    print(radius)
    print("Calibrated Center X = %s +/- %s" % (np.average(best_x), np.std(best_x)))
    print("Calibrated Center Y = %s +/- %s" % (np.average(best_y), np.std(best_y)))
    return np.array([[np.average(best_x), np.std(best_x)], [np.average(best_y), np.std(best_y)]])

In [46]:
s1 = find_center(sparcs.data)


290
Calibrated Center X = 457.0 +/- 0.0
Calibrated Center Y = 601.0 +/- 0.0

In [47]:
s2 = find_center(no_sparcs.data)


295
Calibrated Center X = 443.0 +/- 0.0
Calibrated Center Y = 681.0 +/- 0.0

sun is 290 pixels across which is equivalent to 30 arcminutes


In [48]:
30*60/(2*290.)


Out[48]:
3.103448275862069

In [49]:
print(s1)
print(s2)


[[ 457.    0.]
 [ 601.    0.]]
[[ 443.    0.]
 [ 681.    0.]]

In [50]:
((s1[0][0] - s2[0][0])*3.1)/60.0


Out[50]:
0.72333333333333327

In [51]:
((s1[1][0] - s2[1][0])*3.1)/60.0


Out[51]:
-4.1333333333333337

In [52]:
plt.figure()
plt.imshow(sparcs.data, cmap=cm.Greys_r, origin='upper')
xy = np.shape(no_sparcs.data)
plt.contour(no_sparcs.data)
plt.axhline(s1[0][0], color='r')
plt.axhline(s2[0][0], color='b')
plt.axvline(s1[1][0], color='r')
plt.axvline(s2[1][0], color='b')


Out[52]:
<matplotlib.lines.Line2D at 0x10b85a950>

In [53]:
f = dir + 'FOXSI_SAAS_141113_224732.fits'
img = image(f)

In [54]:
img.roi_reset()
fig = plt.figure()
ax = plt.imshow(img.data, cmap=cm.Greys_r, origin='lower')
circle1 = plt.Circle(img.calibrated_center, 15*60/3.1, fill=False, color='r')
circle2 = plt.Circle(img.calibrated_center, 7.5*60/3.1, fill=False, color='r')
circle3 = plt.Circle(img.calibrated_center, 3*60/3.1, fill=False, color='r')
ax.axes.add_artist(circle1)
ax.axes.add_artist(circle2)
ax.axes.add_artist(circle3)

plt.axvline(img.calibrated_center[0])
plt.axhline(img.calibrated_center[1])


Out[54]:
<matplotlib.lines.Line2D at 0x10b7cde90>

In [55]:
plt.hist(np.ravel(sparcs.data))


Out[55]:
(array([ 973675.,   24923.,    6906.,    6795.,    6701.,   11297.,
          19138.,   30077.,  123788.,   48636.]),
 array([  0. ,   8.8,  17.6,  26.4,  35.2,  44. ,  52.8,  61.6,  70.4,
         79.2,  88. ]),
 <a list of 10 Patch objects>)

Nov 14-2014


In [56]:
sparcs_on = dir + 'FOXSI_SAAS_141114_174035.fits'

In [57]:
sparcs_on = image(sparcs_on)

In [58]:
#x = find_center(sparcs_on.data)

In [59]:
ax = plt.imshow(sparcs_on.data, origin="upper")
circle = plt.Circle((1296/2, 966/2), 0.5*0.5*60*60/3.1, fill=False)
ax.axes.add_patch(circle)
#plt.plot(x[1][0], x[0][0], 'x')


Out[59]:
<matplotlib.patches.Circle at 0x10381be90>

In [60]:
np.shape(sparcs_on.data)


Out[60]:
(966, 1296)

arcminute shift in y direction is


In [61]:
#((x[0][0] - 966/2)*3.1)/60.0

arcminute shift in x direction is


In [62]:
#((x[1][0] - 1296/2)*3.1)/60.0

This agres very well with SPARCS offsets when we centered using the SAAS

SAAS Calibrated Center - 15-Nov-2014


In [63]:
filename = dir + 'FOXSI_SAAS_141115_162920.fits'

In [64]:
saas_cal = image(filename)

In [65]:
plt.imshow(saas_cal.data, origin="upper")


Out[65]:
<matplotlib.image.AxesImage at 0x11e1dbc90>

In [66]:
saas_cal.imshow()
saas_cal.overlay()



In [67]:
saas_cal.max_index


Out[67]:
(483, 659)

In [68]:
saas_cal.data.max()


Out[68]:
38

In [69]:
saas_cal.header


Out[69]:
SIMPLE  =                    T / file does conform to FITS standard             
BITPIX  =                    8 / Bit depth of image                             
NAXIS   =                    0 / number of data axes                            
EXTEND  =                    T / FITS dataset may contain extensions            
COMMENT   FITS (Flexible Image Transport System) format is defined in 'Astronomy
COMMENT   and Astrophysics', volume 376, page 359; bibcode: 2001A&A...376..359H 
TELESCOP= 'FOXSI   '           / Name of source telescope package               
INSTRUME= 'SAAS    '           / Name of instrument                             
ORIGIN  = 'FOXSI/SAAS SBC'     / Location where file was made                   
WAVELNTH=                 6300 / Wavelength of observation (ang)                
WAVE_STR= '630 Nm  '           / Wavelength of observation string               
BZERO   =                  128 / Bit depth of image                             
BSCALE  =                   1. / Bit depth of image                             
WAVEUNIT= 'angstrom'           / Units of WAVELNTH                              
PIXLUNIT= 'DN      '           / Pixel units                                    
IMG_TYPE= 'LIGHT   '           / Image type                                     
RSUN_REF=           696000000.                                                  
CTLMODE = 'LIGHT   '           / Image type                                     
LVL_NUM =                    0 / Level of data                                  
RSUN_OBS=                   0.                                                  
CTYPE1  = 'HPLN-TAN'           / A string value labeling each coordinate axis   
CTYPE2  = 'HPLN-TAN'           / A string value labeling each coordinate axis   
CUNIT1  = 'arcsec  '           / Coordinate Units                               
CUNIT2  = 'arcsec  '           / Coordinate Units                               
CRVAL1  =                   0. / Coordinate value of the reference pixel        
CRVAL2  =                   0. / Coordinate value of the reference pixel        
CDELT1  =     3.09999990463257 / Plate scale                                    
CDELT2  =     3.09999990463257 / Plate scale                                    
CRPIX1  =                   0. / Reference pixel                                
CRPIX2  =                   0. / Reference pixel                                
EXPTIME =                0.033 / Exposure time in seconds                       
DATE_OBS= 'Sat Nov 15 16:29:20 2014 ' / Date and time when observation of this i
TEMPCCD =                30.25 / Temperature of camera in Celsius               
FILENAME= 'FOXSI_SAAS_141115_162920.fits' / Name of the data file               
CAMERAID=               530033 / Serial Number of camera                        
EXPOSURE=                33000 / Exposure time in usec                          
GAIN_PRE=                   3. / Preamp gain of CCD                             
GAIN_ANA=                  100 / Analog gain of CCD                             
FRAMENUM=                 5813 / Frame number                                   

In [70]:
from saaspy.image import image

In [71]:
s = image(filename = dir + 'FOXSI_SAAS_141115_162920.fits')

In [72]:
s.gain_analog


Out[72]:
100

In [73]:
s.header.get("GAIN_PRE")


Out[73]:
3.0

In [74]:
from saaspy.collection import collection

In [75]:
d = collection(fits_files[2:])

Shift of Calibrated Center as a Function of Temperature


In [76]:
temp_files = ['FOXSI_SAAS_141115_235253', 'FOXSI_SAAS_141116_000435', 'FOXSI_SAAS_141116_001714', 
              'FOXSI_SAAS_141116_002646', 'FOXSI_SAAS_141116_003259', 'FOXSI_SAAS_141116_003901', 
              'FOXSI_SAAS_141116_004555', 'FOXSI_SAAS_141116_005338', 'FOXSI_SAAS_141116_010201',
              'FOXSI_SAAS_141116_011211', 'FOXSI_SAAS_141116_012352', 'FOXSI_SAAS_141116_013642', 
              'FOXSI_SAAS_141116_014001', 'FOXSI_SAAS_141116_015814']
temp_files = [dir + f + '.fits' for f in temp_files]
temperatures = np.array([-18.9, -35, -35, -30, -25, -20, -15, -10, -5, 0, 5, 9.5, 10.7, 15])

In [77]:
temp_files


Out[77]:
['/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141115_235253.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_000435.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_001714.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_002646.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_003259.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_003901.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_004555.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_005338.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_010201.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_011211.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_012352.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_013642.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_014001.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141116_015814.fits']

In [78]:
s = []
for f in temp_files:
    s.append(image(f))

In [79]:
cl = collection(temp_files)

In [80]:
cl.data.plot(subplots=True)


Out[80]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x11f0d4910>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x11f697f50>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x11f711d90>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x11f08dbd0>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x11e5b94d0>], dtype=object)

In [81]:
x = cl.data['mindex_x']
y = cl.data['mindex_y']

In [82]:
x.min()


Out[82]:
441

In [83]:
fig, ax = plt.subplots(nrows=3, sharex=True)
ax[0].plot(temperatures, x)
ax[0].set_xlabel('Temperature [C]')
ax[0].set_ylabel('X pixel')
ax[1].plot(temperatures, y)
ax[1].set_ylabel('Y pixel')
ax[2].plot(temperatures, np.sqrt(x ** 2 + y ** 2))
ax[2].set_ylabel('R pixel')


Out[83]:
<matplotlib.text.Text at 0x10fb1b1d0>

In [84]:
fig, ax = plt.subplots(nrows=3, sharex=True)
ax[0].plot(temperatures, (x - x.min()) * 3.1, 'o')
ax[0].set_ylabel('X [arcsec]')
ax[1].plot(temperatures, (y - y.min()) * 3.1, 'o')
ax[1].set_ylabel('Y [arcsec]')
ax[2].plot(temperatures, np.sqrt(((x - x.min())* 3.1) ** 2 + ((y - y.min())* 3.1) ** 2), 'o')
ax[2].set_ylabel('R [arcsec]')
fit = np.polyfit( temperatures, np.sqrt(((x - x.min())* 3.1) ** 2 + ((y - y.min())* 3.1) ** 2), deg=1)
yfit = lambda x: fit[1] + x * fit[0]
ax[2].plot(temperatures, yfit(temperatures), 'r-')
ax[2].set_xlabel('Temperature [C]')
print('fit result: y = mx + b, m = %f, b = %f' % (fit[0], fit[1]))


fit result: y = mx + b, m = 2.318877, b = 88.892403

The camera shifts by 2.3 arcsec per degree

All files


In [85]:
fits_files = glob.glob(dir + 'FOXSI_SAAS*')

In [86]:
print('Number of file = %i' % len(fits_files))


Number of file = 160

In [87]:
cl = collection(fits_files[50:])

In [88]:
fits_files[0]


Out[88]:
'/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141106_230612.fits'

In [89]:
for i, f in enumerate(fits_files):
    print(i, f)
    image(f)


(0, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141106_230612.fits')
(1, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141107_141253.fits')
(2, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141107_142626.fits')
(3, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141107_143202.fits')
(4, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_003939.fits')
(5, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_004104.fits')
(6, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_004207.fits')
(7, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_005541.fits')
(8, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_005550.fits')
(9, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_005618.fits')
(10, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_005624.fits')
(11, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_181429.fits')
(12, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_181618.fits')
(13, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_182017.fits')
(14, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_182020.fits')
(15, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_182021.fits')
(16, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_182023.fits')
(17, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_182040.fits')
(18, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_182042.fits')
(19, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_183337.fits')
(20, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_183340.fits')
(21, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_183342.fits')
(22, '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141108_183344.fits')
WARNING: File may have been truncated: actual file length (16384) is smaller than the expected size (17280) [astropy.io.fits.file]
WARNING:astropy:File may have been truncated: actual file length (16384) is smaller than the expected size (17280)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-89-6f68022e28cf> in <module>()
      1 for i, f in enumerate(fits_files):
      2     print(i, f)
----> 3     image(f)

/Users/schriste/Developer/repositories/SAASpy/saaspy/image.py in __init__(self, filename)
     41 
     42         if f is not None:
---> 43             self.data = f[1].data
     44             self.data = self.data.astype(np.ubyte)
     45             self.header = f[0].header

/Users/schriste/anaconda/lib/python2.7/site-packages/astropy/utils/misc.pyc in __get__(self, obj, owner)
    286             return obj.__dict__[self._key]
    287         except KeyError:
--> 288             val = self._fget(obj)
    289             obj.__dict__[self._key] = val
    290             return val

/Users/schriste/anaconda/lib/python2.7/site-packages/astropy/io/fits/hdu/compressed.pyc in data(self)
   1371     def data(self):
   1372         # The data attribute is the image data (not the table data).
-> 1373         data = compression.decompress_hdu(self)
   1374 
   1375         if data is None:

/Users/schriste/anaconda/lib/python2.7/site-packages/astropy/utils/misc.pyc in __get__(self, obj, owner)
    286             return obj.__dict__[self._key]
    287         except KeyError:
--> 288             val = self._fget(obj)
    289             obj.__dict__[self._key] = val
    290             return val

/Users/schriste/anaconda/lib/python2.7/site-packages/astropy/io/fits/hdu/compressed.pyc in compressed_data(self)
   1419         # First we will get the table data (the compressed
   1420         # data) from the file, if there is any.
-> 1421         compressed_data = super(BinTableHDU, self).data
   1422         if isinstance(compressed_data, np.rec.recarray):
   1423             del self.data

/Users/schriste/anaconda/lib/python2.7/site-packages/astropy/utils/misc.pyc in __get__(self, obj, owner)
    286             return obj.__dict__[self._key]
    287         except KeyError:
--> 288             val = self._fget(obj)
    289             obj.__dict__[self._key] = val
    290             return val

/Users/schriste/anaconda/lib/python2.7/site-packages/astropy/io/fits/hdu/table.pyc in data(self)
    348     @lazyproperty
    349     def data(self):
--> 350         data = self._get_tbdata()
    351         data._coldefs = self.columns
    352         data.formats = self.columns.formats

/Users/schriste/anaconda/lib/python2.7/site-packages/astropy/io/fits/hdu/table.pyc in _get_tbdata(self)
    145             # We have a heap; include it in the raw_data
    146             raw_data = self._get_raw_data(self._data_size, np.uint8,
--> 147                                           self._data_offset)
    148             data = raw_data[:self._theap].view(dtype=columns.dtype,
    149                                                type=np.rec.recarray)

/Users/schriste/anaconda/lib/python2.7/site-packages/astropy/io/fits/hdu/base.pyc in _get_raw_data(self, shape, code, offset)
    522                               offset=offset)
    523         elif self._file:
--> 524             return self._file.readarray(offset=offset, dtype=code, shape=shape)
    525         else:
    526             return None

/Users/schriste/anaconda/lib/python2.7/site-packages/astropy/io/fits/file.pyc in readarray(self, size, offset, dtype, shape)
    260             return Memmap(self.__file, offset=offset,
    261                           mode=MEMMAP_MODES[self.mode], dtype=dtype,
--> 262                           shape=shape).view(np.ndarray)
    263         else:
    264             count = reduce(lambda x, y: x * y, shape)

/Users/schriste/anaconda/lib/python2.7/site-packages/numpy/core/memmap.pyc in __new__(subtype, filename, dtype, mode, offset, shape, order)
    255         bytes -= start
    256         offset -= start
--> 257         mm = mmap.mmap(fid.fileno(), bytes, access=acc, offset=start)
    258 
    259         self = ndarray.__new__(subtype, shape, dtype=descr, buffer=mm,

ValueError: mmap length is greater than file size

In [ ]:
cl.data

In [ ]:
cl.data['std'].plot()

Sun Images (14-Nov-2014)


In [90]:
files = glob.glob(dir + 'FOXSI_SAAS_141114_1*')

In [91]:
cl = collection(files)

In [92]:
cl.data


Out[92]:
filename max min mindex_x mindex_y std
2014-11-14 17:20:13 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 89 2 280 475 29.240931
2014-11-14 17:24:33 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 89 2 280 475 24.542582
2014-11-14 17:24:39 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 89 2 280 475 28.720315
2014-11-14 17:25:23 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 88 2 280 475 28.314749
2014-11-14 17:25:26 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 88 2 280 475 28.344746
2014-11-14 17:28:27 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 62 0 428 639 18.812836
2014-11-14 17:30:03 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 89 0 392 661 27.094800
2014-11-14 17:31:28 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 68 1 485 613 19.321366
2014-11-14 17:32:01 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 80 2 344 660 22.482996
2014-11-14 17:34:05 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 90 2 380 663 25.901004
2014-11-14 17:34:40 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 42.353471
2014-11-14 17:38:18 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 94 1 464 555 26.725422
2014-11-14 17:40:33 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 41.131422
2014-11-14 17:40:35 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 41.006146
2014-11-14 17:41:05 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 129 2 374 719 38.271819
2014-11-14 18:12:37 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 133 3 280 475 41.236127
2014-11-14 18:15:20 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 133 3 321 332 41.718275
2014-11-14 18:49:20 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.884019
2014-11-14 18:49:21 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.881539
2014-11-14 18:49:22 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.904239
2014-11-14 18:49:23 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.863996
2014-11-14 18:49:24 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.936843
2014-11-14 18:49:25 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.924625
2014-11-14 18:49:26 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.914922
2014-11-14 18:49:27 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.922266
2014-11-14 18:49:28 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.890611
2014-11-14 18:49:29 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.934255
2014-11-14 18:49:30 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.851448
2014-11-14 18:49:31 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.884028
2014-11-14 18:49:32 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.893536
... ... ... ... ... ... ...
2014-11-14 18:49:42 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.894506
2014-11-14 18:49:43 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.914204
2014-11-14 18:49:44 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.867023
2014-11-14 18:49:45 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.834456
2014-11-14 18:49:46 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.777008
2014-11-14 18:49:47 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.827292
2014-11-14 18:49:48 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.778089
2014-11-14 18:49:49 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.737904
2014-11-14 18:49:50 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.761171
2014-11-14 18:52:30 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.950584
2014-11-14 18:52:31 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.975856
2014-11-14 18:52:32 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.988573
2014-11-14 18:52:33 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 132 2 336 664 43.897351
2014-11-14 18:52:34 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.992681
2014-11-14 18:52:35 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.937255
2014-11-14 18:52:36 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.955187
2014-11-14 18:52:37 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.951188
2014-11-14 18:52:38 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 44.001665
2014-11-14 18:52:39 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.886661
2014-11-14 18:52:40 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.908908
2014-11-14 18:52:41 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.909305
2014-11-14 18:52:42 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.958370
2014-11-14 18:52:43 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.950667
2014-11-14 18:52:44 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.923002
2014-11-14 18:52:45 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.988264
2014-11-14 18:52:46 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.926889
2014-11-14 18:52:47 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 132 2 527 488 43.899027
2014-11-14 18:52:48 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.979445
2014-11-14 18:52:49 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.944572
2014-11-14 18:52:50 /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114... 131 2 336 664 43.967994

69 rows × 6 columns


In [93]:
cl.data['max'].max()


Out[93]:
133

In [94]:
files[0]


Out[94]:
'/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141114_172013.fits'

In [95]:
s = image(files[0])

In [96]:
s.imshow()



In [97]:
s.gain_analog, s.gain_preamp, s.exposure


Out[97]:
(0, -3.0, 0.03)

In [98]:
plt.figure(figsize=(18,4))
ax = plt.hist(s.data.ravel(), bins=np.arange(1,255,1), log=True)
plt.xlim(0,255)
plt.show()



In [105]:
plt.plot(s.data[450, :])


Out[105]:
[<matplotlib.lines.Line2D at 0x12a9c0d90>]

In [131]:
s = image(files[8])
plt.figure(figsize=(15,15))
plt.imshow(s.data[150:750,300:1000], cmap=plt.cm.Greys_r)
plt.colorbar()
plt.title("Active Regions")
print(s.gain_analog, s.gain_preamp, s.exposure)
print(s.max)
plt.show()


(100, -3.0, 0.03)
80

Calibrated Center X-ray Alignment (Phasing Check) 2


In [101]:
file = dir + 'FOXSI_SAAS_141115_213723.fits'
s = image(file)

In [102]:
s.imshow()
plt.xlim(600, 700)
plt.ylim(400, 500)
plt.plot(645, 453, 'x')


Out[102]:
[<matplotlib.lines.Line2D at 0x12147a790>]

In [104]:
file = dir + 'FOXSI_SAAS_141115_235253.fits'
s = image(file)

In [105]:
s.imshow()
plt.xlim(600, 700)
plt.ylim(400, 500)
plt.plot(645, 453, 'x')


Out[105]:
[<matplotlib.lines.Line2D at 0x1284b4b50>]

In [11]:
s.center_of_mass + np.array([s.roi[2], s.roi[0]])


Out[11]:
array([ 453.15899031,  645.13217901])

In [9]:
s.max_index


Out[9]:
(453, 646)

In [10]:
s.roi


Out[10]:
array([ 596.,  696.,  403.,  503.])

SPARCS & SAAS Alignment (2014/11/20)


In [4]:
files = glob.glob(dir + "FOXSI_SAAS_141120_09*")

In [5]:
files


Out[5]:
['/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_092938.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093656.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093657.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093658.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093659.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093700.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093701.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093702.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093703.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093704.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093705.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093706.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093707.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093708.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093709.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093710.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093711.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093712.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093713.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093714.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093715.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093716.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093717.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093718.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093719.fits',
 '/Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120_093720.fits']

In [6]:
cl = collection(files)

In [7]:
cl.data


Out[7]:
com filename max min mindex_x mindex_y std
2014-11-20 09:29:38 (415.251254438, 689.110001088) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 165 0 361 716 53.417414
2014-11-20 09:36:56 (411.323807843, 683.086039334) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 354 686 52.667598
2014-11-20 09:36:57 (410.349434979, 686.383614976) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 363 668 52.659995
2014-11-20 09:36:58 (410.891964358, 685.743171172) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 163 0 410 647 52.672832
2014-11-20 09:36:59 (411.277510855, 685.704346128) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 164 0 368 675 52.591817
2014-11-20 09:37:00 (411.437509127, 686.052224298) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 359 662 52.645847
2014-11-20 09:37:01 (410.665387353, 682.004957774) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 349 683 52.593426
2014-11-20 09:37:02 (412.086516469, 682.723488378) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 163 0 385 722 52.576721
2014-11-20 09:37:03 (412.668737039, 684.264158567) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 347 664 52.553418
2014-11-20 09:37:04 (410.898398188, 685.150069586) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 163 0 418 720 52.609520
2014-11-20 09:37:05 (410.826290671, 685.168129675) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 400 688 52.605597
2014-11-20 09:37:06 (411.519589642, 684.830355373) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 165 0 396 656 52.589141
2014-11-20 09:37:07 (410.886916547, 686.060880286) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 385 685 52.563088
2014-11-20 09:37:08 (410.677427109, 684.562873447) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 400 699 52.629540
2014-11-20 09:37:09 (409.165075928, 683.819768586) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 163 0 367 692 52.605333
2014-11-20 09:37:10 (409.285877026, 688.54614853) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 355 689 52.672621
2014-11-20 09:37:11 (409.239445856, 685.618038118) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 397 683 52.546928
2014-11-20 09:37:12 (410.678523718, 683.123055772) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 339 674 52.507355
2014-11-20 09:37:13 (410.588540038, 682.632098179) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 163 0 392 726 52.600745
2014-11-20 09:37:14 (411.963032948, 683.574065149) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 163 0 390 714 52.560658
2014-11-20 09:37:15 (412.360317376, 684.760429177) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 406 676 52.532244
2014-11-20 09:37:16 (410.556005813, 685.930213536) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 163 0 361 728 52.576438
2014-11-20 09:37:17 (410.14447512, 684.991381716) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 354 686 52.554866
2014-11-20 09:37:18 (409.663189322, 684.326335796) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 163 0 383 716 52.583351
2014-11-20 09:37:19 (410.504868662, 684.830678358) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 164 0 421 707 52.528821
2014-11-20 09:37:20 (410.563282099, 686.938120881) /Users/schriste/Desktop/SAAS/FOXSI_SAAS_141120... 162 0 371 669 52.581744

Using center of mass method


In [8]:
xcom = [x[0] for x in cl.data['com']]
ycom = [x[1] for x in cl.data['com']]

In [9]:
plt.plot(xcom, ycom, 'x')
plt.title("Center of Mass")


Out[9]:
<matplotlib.text.Text at 0x109ca7ad0>

In [10]:
s = image(files[0])

In [11]:
s.calibrated_center


Out[11]:
array([645, 453])

In [12]:
xcal = s.calibrated_center[1]
ycal = s.calibrated_center[0]

In [13]:
offset_x = [xcal - x for x in xcom]
offset_y = [ycal - x for x in ycom]

In [14]:
plt.plot(offset_x, offset_y, 'x')
plt.plot(np.average(offset_x), np.average(offset_y), 'o')
plt.errorbar(np.average(offset_x), np.average(offset_y), yerr=np.std(offset_y), xerr=np.std(offset_x))
plt.title("Offset in Pixels")
plt.xlabel('X')
plt.ylabel('Y')


Out[14]:
<matplotlib.text.Text at 0x10aca5910>

The Solar radius 970.38 arcsec on Nov 25, 2014


In [15]:
x = []
y = []
for f in files:
    xy = find_center(image(f), num_circles=1, sigma=1.3)
    x.append(xy[0][0])
    y.append(xy[1][0])
print(x)


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-15-e919e7d07e17> in <module>()
      4     xy = find_center(image(f), num_circles=1, sigma=1.3)
      5     x.append(xy[0][0])
----> 6     y.append(xy[1][0])
      7 print(x)

IndexError: list index out of range

In [16]:
find_center(image(files[0]))


Out[16]:
[[415, 687, 290],
 [419, 697, 290],
 [405, 703, 280],
 [405, 682, 300],
 [420, 676, 280]]

Plate scale calculation


In [22]:
plate_scape = 970.38/(290)
print("Plate Scale %f = " % plate_scape)


Plate Scale 3.346138

In [30]:
plt.plot(np.array(offset_x) * plate_scape/60., np.array(offset_y)* plate_scape/60., 'x')
label = "[%f, %f]" % (np.average(offset_x)* plate_scape/60., np.average(offset_y)* plate_scape/60.)
plt.plot(np.average(offset_x)* plate_scape/60., np.average(offset_y)* plate_scape/60., 'o', label=label)
plt.errorbar(np.average(offset_x)* plate_scape/60., np.average(offset_y)* plate_scape/60., yerr=np.std(offset_y)* plate_scape/60., xerr=np.std(offset_x)* plate_scape/60.)
plt.title("Offset in Pixels")
plt.xlabel('X offset [arcmin]')
plt.ylabel('Y offset [arcmin]')
plt.legend()


Out[30]:
<matplotlib.legend.Legend at 0x10babfbd0>

Post-Vibe SAAS Alignment (30-Nov-2014)


In [6]:
file = dir + 'FOXSI_SAAS_141130_110145.fits'

In [7]:
s = image(file)

In [8]:
previous_calibrated_center = np.array([645, 453])

In [9]:
s.max


Out[9]:
50

In [10]:
s.imshow()
plt.xlim(600,750)
plt.ylim(400, 550)
plt.plot(previous_calibrated_center[0], previous_calibrated_center[1], 'x', label="pre-vibe")
new_calib_center = np.array([676, 472])
plt.plot(new_calib_center[0], new_calib_center[1], 'o', label="post-vibe")
plt.legend()


Out[10]:
<matplotlib.legend.Legend at 0x10b308bd0>

In [11]:
print("Pre-vibe calib center", previous_calibrated_center)
print("Post-vibe calib center", new_calib_center)
print("Difference", (previous_calibrated_center - new_calib_center)*s.plate_scale/60.)
print("Shift", np.sqrt(np.sum(np.power(previous_calibrated_center - new_calib_center, 2)))*s.plate_scale/60.0)


('Pre-vibe calib center', array([645, 453]))
('Post-vibe calib center', array([676, 472]))
('Difference', array([-1.60166662, -0.98166664]))
('Shift', 1.8785647016871989)

Heliostat Testing (1-Dec-2014)

Pre-shim image


In [37]:
file = dir + 'FOXSI_SAAS_141201_065826.fits'

In [38]:
s = image(file)
s.imshow()
plt.plot(new_calib_center[0], new_calib_center[1], '+', label="post-vibe calib center")
plt.plot(previous_calibrated_center[0], previous_calibrated_center[1], 'x', label="pre-vibe")
plt.legend()


Out[38]:
<matplotlib.legend.Legend at 0x10a9dea50>

In [39]:
r = find_center(s, plot=True, num_circles=1)
print(r)


[[549, 696, 280]]

In [40]:
y = r[0][0]
x = r[0][1]
print(x, y)


(696, 549)

In [41]:
sun_center = r[0][0:2]
print(sun_center)


[549, 696]

In [44]:
s = image(file)
s.imshow()
plt.plot(new_calib_center[0], new_calib_center[1], '+', label="post-vibe calib center")
plt.plot(x, y, 'x', label='sun center')
plt.plot(previous_calibrated_center[0], previous_calibrated_center[1], '+', label="pre-vibe")
plt.legend()


Out[44]:
<matplotlib.legend.Legend at 0x10e807850>

shift is compared to pre-vibe alignment (this value given to Chris to make shims)


In [47]:
(np.array([x,y]) - previous_calibrated_center) * s.plate_scale/60.0


Out[47]:
array([ 2.63499992,  4.95999985])

shift is compared to post-vibe alignment (what we really needed to shim)


In [45]:
(np.array([x,y]) - new_calib_center) * s.plate_scale/60.0


Out[45]:
array([ 1.0333333 ,  3.97833321])

Post-shim image (maybe)


In [ ]:
file = dir + 'FOXSI_SAAS_141201_085533.fits'
s = image(file)

In [50]:
s.imshow()
plt.plot(new_calib_center[0], new_calib_center[1], '+', label="post-vibe calib center")
plt.plot(previous_calibrated_center[0], previous_calibrated_center[1], '+', label="pre-vibe")
plt.plot(s.center_of_mass[1], s.center_of_mass[0], 'x', label='sun center')
plt.legend()


Out[50]:
<matplotlib.legend.Legend at 0x10fff76d0>

Heliostat Testing (2-Dec-2014)


In [27]:
file = dir + 'FOXSI_SAAS_141202_072511.fits'
s = image(file)

In [28]:
r = find_center(s, plot=True, num_circles=1)
sun_center = r[0][0:2]



In [30]:
s.imshow()
plt.plot(new_calib_center[0], new_calib_center[1], '+', label="post-vibe calib center")
plt.plot(s.center_of_mass[1], s.center_of_mass[0], '+', label='center of mass')
plt.plot(sun_center[1], sun_center[0], 'xb', label='sun center')
plt.legend()


Out[30]:
<matplotlib.legend.Legend at 0x10ae34bd0>

SAAS to LISS misalignment measurement (after shim)


In [51]:
file = dir + 'FOXSI_SAAS_141202_074421.fits'
s = image(file)

In [52]:
fig, ax1 = plt.subplots(1, 1, figsize=(8, 6))
s.imshow()
plt.plot(new_calib_center[0], new_calib_center[1], 'o', label="post-vibe calib center")
#plt.plot(s.center_of_mass[1], s.center_of_mass[0], 'x')
#plt.plot(sun_center[1], sun_center[0], 'xb', label='sun center')
sun_center = (620, 485)
circle = plt.Circle(sun_center, radius=280, color='r', fill=False)
plt.plot(sun_center[0], sun_center[1], 'x', label='Sun Center')
ax1.add_patch(circle)
plt.legend()
plt.show()


SAAS to LISS misalignment is


In [53]:
(new_calib_center - sun_center) * s.plate_scale/60.0


Out[53]:
array([ 2.89333324, -0.67166665])

checking next image which should be the same


In [54]:
file = dir + 'FOXSI_SAAS_141202_074414.fits'
s = image(file)

In [55]:
fig, ax1 = plt.subplots(1, 1, figsize=(8, 6))
s.imshow()
plt.plot(new_calib_center[0], new_calib_center[1], 'o', label="post-vibe calib center")
#plt.plot(s.center_of_mass[1], s.center_of_mass[0], 'x')
#plt.plot(sun_center[1], sun_center[0], 'xb', label='sun center')
sun_center = (620, 485)
circle = plt.Circle(sun_center, radius=280, color='r', fill=False)
plt.plot(sun_center[0], sun_center[1], 'x', label='Sun Center')
ax1.add_patch(circle)
plt.legend()
plt.show()



In [ ]: